//
//  ViewController.swift
//  NDStudentModule
//
//  Created by weiyanlong on 10/06/2019.
//  Copyright (c) 2019 weiyanlong. All rights reserved.
//

import UIKit
import NDStudentModule
import URLNavigator

class ViewController: UIViewController {

    @IBOutlet weak var TpImageView: UIImageView!
    
    let navigator = Navigator()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        StudentTest.log()
//        navigator.register("myapp://user") { (url, values, context) -> UIViewController? in
//            return StudentViewController()
//        }
        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        let vc = StudentViewController()
        self.present(vc, animated: true, completion: nil)
        
//        StudentTest3.openFrom(vc: self)
//        navigator.presentURL("myapp://user")
//        currentViewController()?.present(vc, animated: true, completion: nil)
    }
    func currentViewController(base: UIViewController? = UIApplication.shared.keyWindow?.rootViewController) -> UIViewController? {
        if let nav = base as? UINavigationController {
            return currentViewController(base: nav.visibleViewController)
        }
        if let tab = base as? UITabBarController {
            return currentViewController(base: tab.selectedViewController)
        }
        if let presented = base?.presentedViewController {
            return currentViewController(base: presented)
        }
        return base
    }

}

